﻿#include "OperGeometryLine.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "OperatorsInterface/GraphEventOperator.h"
#include <QWidget>
#include "GUIDialog/GUIGeometryDialog/GUIGeometryLineDialog.h"
#include "GUIDialog/GUIGeometryDialog/GUIGeometryVerticalLineDialog.h"

bool ModelOper::OperGeometryLine::execGUI(){
    //获取动作名称
    if (_emitter==nullptr)
    {
        return false;
    }
    QString actionName = _emitter->objectName();
    if (actionName == "actionLineNodes")//由点构线
    {
        this->createLineNodesOper();
    }
    else if (actionName == "actionLineVerticalLine")
    {
        this->createVerticalLineOper();
    }
    return false;
}

bool ModelOper::OperGeometryLine::execProfession()
{
    int objID = -1;
    this->argValue("objID", objID);
    //获取三维可视对象数据-用于渲染数据对象
    EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
    if (graphOper == nullptr)return false;
    graphOper->updateGraph(objID);
    return true;
}

bool ModelOper::OperGeometryLine::createLineNodesOper()
{
    //主界面
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建界面
    GUI::GUIGeometryLineDialog* dialog = new GUI::GUIGeometryLineDialog(this,mw);

    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometryLine::execProfession);
    dialog->show();
    return true;
}


bool ModelOper::OperGeometryLine::createVerticalLineOper()
{
    //主界面
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建界面
    GUI::GUIGeometryVerticalLineDialog* dialog = new GUI::GUIGeometryVerticalLineDialog(this, mw);

    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometryLine::execProfession);
    dialog->show();
    return true;
}
